#!/usr/bin/env python

# $LastChangedBy$
# $LastChangedRevision$
# $LastChangedDate$
# $HeadURL$

"""
Life.py: An object that contains an entire life
"""

__author__ = "Andrew Trettel and Ben Trettel"
__copyright__ = "Copyright 2012, Andrew Trettel and Ben Trettel"
__credits__ = ["Andrew Trettel", "Ben Trettel"]
__license__ = "GPL v2"
__version__ = "0.01"
__maintainer__ = "Andrew Trettel"
__status__ = "Prototype"

import datetime

class Life:
   # Instance variables
   name = ""
   birthday = datetime.date.today()
   gender = -1 # 1 for male, 0 for female
   days = []   # Dictionary by date may be better

   # Getters
   def getName(self):
      return self.name

   def getBirthday(self):
      return self.birthday

   def getGender(self):
      return self.gender

   def getGenderString(self):
      if self.gender==0:
         return "Female"
      elif self.gender==1:
         return "Male"
      else:
         return "Undefined"

   def getNumberOfDays(self):
      return len(self.days)

   def getProfile(self):
      return self.name+": "+self.getGenderString()+" -- "+str(self.getNumberOfDays())+" days long"

   def getDay(self, index):
      return self.days[index]

   # Setters
   def setName(self, name):
      self.name = name

   def setBirthday(self, birthday):
      self.birthday = birthday

   def setGender(self, gender):
      self.gender = gender

   # Days
   def addDay(self, day):
      day.setGender(self.gender)
      day.setBirthday(self.birthday)
      self.days.append(day)

   # Getters
   def getDates(self):
      dates = []
      for day in self.days:
         dates.append( day.getDate() )
      return dates

   def getDaysSinceDate(self, firstDate):
      daysSinceFirstDay = []
      for day in self.days:
         daysSinceFirstDay.append( day.getDaysSinceDate( firstDate ) )
      return daysSinceFirstDay

   def getAgesInDays(self):
      agesInDays = []
      for day in self.days:
         agesInDays.append( day.getAgeInDays() )
      return agesInDays

   def getAgesInYears(self):
      agesInYears = []
      for day in self.days:
         agesInYears.append( day.getAgeInYears() )
      return agesInYears

   def getHeights(self):
      heights = []
      for day in self.days:
         heights.append( day.getHeight() )
      return heights

   def getWeights(self):
      weights = []
      for day in self.days:
         weights.append( day.getWeight() )
      return weights

   def getBMIs(self):
      bmis = []
      for day in self.days:
         bmis.append( day.getBMI() )
      return bmis

   def calculateREEs(self, method):
      rees = []
      for day in self.days:
         rees.append( day.calculateREE(method) )
      return rees

   def calculateRestingVdotO2s(self, method):
      vdotO2s = []
      for day in self.days:
         vdotO2s.append( day.calculateRestingVdotO2(method) )
      return vdotO2s

   def calculateSpecificRestingVdotO2s(self, method):
      vdotO2s = []
      for day in self.days:
         vdotO2s.append( day.calculateSpecificRestingVdotO2(method) )
      return vdotO2s

   # Constructor
   def __init__(self, name, birthday, gender):
      self.setName(name)
      self.setBirthday(birthday)
      self.setGender(gender)
